class NumArray
{
public:
    NumArray(vector<int> &nums)
    {
        prefixSum = vector<int>(nums.size() + 1);
        partial_sum(nums.begin(), nums.end(), prefixSum.begin() + 1);
    }

    int sumRange(int left, int right)
    {
        return prefixSum[right + 1] - prefixSum[left];
    }

private:
    vector<int> prefixSum;
};

/**
 * Your NumArray object will be instantiated and called as such:
 * NumArray* obj = new NumArray(nums);
 * int param_1 = obj->sumRange(left,right);
 */